home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekikoh Dennoh Club 1
/
Gekikoh Dennoh Club Vol. 1 (Japan).7z
/
Gekikoh Dennoh Club Vol. 1 (Japan) (Track 1).bin
/
kowin
/
archive
/
sys
/
kowin14d.lzh
/
smpl
/
OMAKE
/
smpl.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-12-01
|
3KB
|
142 lines
/* shputlib サンプル 1994 Ogasawara Hiroyuki (COR.) */
#include <corlib.h>
#include "shput.h"
asm( "RAND equ $fe0e" );
DOSCALL int RAND(void);
/*-----------------------------------------------------------------*/
/* かなり手抜き版の移動処理 … shot はもちょっとちゃんと管理してる */
#include "Em007.INC"
struct table {
short x, y, dx, dy;
} Tbl[100];
int SystemCounter= 0;
int x= -16, y= 3;
ObjectInit()
{
int i;
struct table *tp= Tbl;
for( i= 0 ; i< 100 ; i++, tp++ )
tp->x= -1;
}
TableAdd( x, y, dx, dy )
{
int i;
struct table *tp= Tbl;
for( i= 0 ; i< 100 ; i++, tp++ ){
if( tp->x < 0 ){
tp->x= x;
tp->y= y;
tp->dx= dx;
tp->dy= dy;
return;
}
}
}
ObjectMove()
{
int i;
struct table *tp= Tbl;
for( i= 0 ; i< 100 ; i++, tp++ ){
if( tp->x >= 0 ){
Clr4x4( tp->x, tp->y );
tp->x+= tp->dx;
tp->y+= tp->dy;
if( tp->x >= 208 || tp->y < -10 || tp->y >= 100 )
tp->x= -1;
if( tp->x >= 0 )
Put4x4( tp->x, tp->y );
}
}
if( (++SystemCounter) & 1 ){
Clr16x16( x, y );
if( ++x >= 208 ){
x= -16;
y= RAND() % 84;
}
Put16x16( x, y, Em0071 );
if( RAND() % 21 == 3 ){
TableAdd( x+6, y+6, 1, 0 );
TableAdd( x+6, y+6,-1, 0 );
TableAdd( x+6, y+6, 0, 1 );
TableAdd( x+6, y+6, 0,-1 );
TableAdd( x+6, y+6, 1, 1 );
TableAdd( x+6, y+6, 1,-1 );
TableAdd( x+6, y+6,-1, 1 );
TableAdd( x+6, y+6,-1,-1 );
}
}
}
/*-----------------------------------------------------------------*/
/* 以下、ウィンドウ処理部 */
#define EventMask (EventOpenON \
|EventCloseON \
|EventRedrawON \
|EventMouseSwitchON )
#define EventInt (EventMask|EventIntervalON)
#define XOFFSET 0
#define YOFFSET 0
#define XSIZE 208
#define YSIZE 100
static Sheet Vram= { SHXSIZE, SHYSIZE, SHXSIZE/16, vrambuf, vrambuf };
int WAIT= 4;
Exec( wp, info )
WindowID wp;
EventInfo *info;
{
static int Wait;
static DrawBuf Dbuf[2];
switch( info->option ){
case EventInterval:
if( ++Wait < WAIT )
return FALSE;
Wait= 0;
ObjectMove();
WindowDraw( wp, Dbuf+1, 1 );
return TRUE;
case EventOpen:
ObjectInit();
A_Cls();
DrawSetClear( Dbuf, 0 );
DrawSetPut( Dbuf+1, XOFFSET, YOFFSET, &Vram );
WindowRedraw( wp );
WindowSetEventAttr( wp, EventInt );
return TRUE;
case EventClose:
WindowClose( wp );
WindowConnectionClose();
return TRUE;
case EventRedraw:
WindowDraw( wp, Dbuf, 2 );
return TRUE;
}
return FALSE;
}
WindowMain( argc, argv )
char **argv;
{
int x= 434, y= 0;
argc= AnalyzeArgs( argc, argv, &x, &y, 0, 0 );
if( --argc && **++argv == '-' && (*argv)[1] == 'w' )
WAIT= _atoiX( *argv+2 );
WindowTitleOpen( x, y, XSIZE, YSIZE+YOFFSET, NULL,
"shput-sample", Close|Push, Exec );
}